package edu.nf.llmtest.common.converter;


import edu.nf.llmtest.model.document.UserDoc;
import edu.nf.llmtest.model.entity.User;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

@Mapper(componentModel = "spring")
public interface UserConverter {
    @Mappings(
            {
                    @Mapping(source = "userId", target = "userId"),
                    @Mapping(source = "userName", target = "userName"),
                    @Mapping(source = "password", target = "password"),
                    @Mapping(source = "sex", target = "sex"),
                    @Mapping(source = "email", target = "email"),
                    @Mapping(source = "avatar", target = "avatar"),
                    @Mapping(source = "createTime", target = "createTime"),
                    @Mapping(source = "lastLoginTime", target = "lastLoginTime")
            }
    )
    UserDoc convertUserDoc(User user);

    @Mappings(
            {
                    @Mapping(source = "userId", target = "userId"),
                    @Mapping(source = "userName", target = "userName"),
                    @Mapping(source = "password", target = "password"),
                    @Mapping(source = "sex", target = "sex"),
                    @Mapping(source = "email", target = "email"),
                    @Mapping(source = "avatar", target = "avatar"),
                    @Mapping(source = "createTime", target = "createTime"),
                    @Mapping(source = "lastLoginTime", target = "lastLoginTime")
            }
    )
    User convertUser(UserDoc userDoc);
}
